/**
 * 
 */
package com.p2p.base.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.p2p.base.model.LoginCount;

/**
 * @author ruiqi
 *
 */
public interface LoginCountDao {

	@Update("update p2p_login_count set times=times+1,lastLoginTime=NOW(),lastLoginType=#{lastLoginType},lastLoginIp=#{lastLoginIp} where uid=#{uid}")
	int updateSuccessTimes(LoginCount loginCount);
	
	@Update("update p2p_login_count set wrongTimes=wrongTimes+1,lastWrongTime=NOW() where uid=#{uid}")
	int updateWrongTimes(String uid);
	
	@Insert("insert into p2p_login_count(uid,times,lastLoginTime,wrongTimes,lastWrongTime,status)values(#{uid},#{times},NOW(),#{wrongTimes},NOW(),0)")
	void create(LoginCount loginCount);
	
	@Select("select uid,times,lastLoginTime,lastLoginType,lastLoginIp,wrongTimes,lastWrongTime,status from p2p_login_count where uid=#{uid}")
	LoginCount getByUid(String uid);
}
